package com.dcd.controller;

import com.dcd.annotation.MultiRequestBody;
import com.dcd.pojo.Follow_user;
import com.dcd.service.Follow_userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/Follow_userController")
public class Follow_userController {

    @Autowired
    private Follow_userService fs;

    /**
     * 查询所有关注的用户(根据登录用户id查询)
     * @param follow_user_id 登录用户id
     * @return
     */
    @RequestMapping("/select_Follow_user/{follow_user_id}")
    public List<Follow_user> select_Follow_user(@PathVariable int follow_user_id){
        return fs.select_Follow_user(follow_user_id);
    }
    
    /**
     * 根据登入id查询用户详情
     * @param user_id 用户登入id
     * @return
     */
    @RequestMapping("/select_ById/{user_id}")
    public Follow_user select_ById(@PathVariable int user_id){
        return fs.select_ById(user_id);
    }

    /**
     * 根据被关注id查询粉丝数
     * @param cover_id 被关注id
     * @return
     */
    @RequestMapping("/select_By_CoverId/{cover_id}")
    public Follow_user select_By_CoverId(@PathVariable int cover_id){
        return fs.select_By_CoverId(cover_id);
    }

    /**
     * 根据条件添加，取消关注
     * @param follow_user 关注用户表的对象
     * @return
     */
    @RequestMapping("/insert_or_delete_follow_user_id")
    public String insert_or_delete_follow_user_id(@MultiRequestBody Follow_user follow_user, @MultiRequestBody String type){
          return fs.insert_or_delete_follow_user_id(follow_user,type);
    }

    @RequestMapping("/select_Guanzhu_and_Fensi_ById/{user_id}")
    public Map<String,Object> select_Guanzhu_and_Fensi_ById(@PathVariable int user_id){
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("GuanZhu",fs.select_ById(user_id));
        map.put("FenSi",fs.select_By_CoverId(user_id));
        return map;
    }

    /**
     * 查询用户是否关注指定用户
     * @param follow_user
     * @return
     */
    @RequestMapping("/select_user_follow_user")
    public String select_user_follow_user(@MultiRequestBody Follow_user follow_user){
        return fs.select_user_follow_user(follow_user);
    }

}
